﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WoBian.ServiceModel;
using WoBian.Lib.ConstString;
using System.Collections.Specialized;

namespace WoBian.Controllers.Common
{
    public class AdminController : BaseController
    {
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {                
                //if (string.IsNullOrEmpty(MyApplicationContext.Current.UserId))
                //{
                //    filterContext.Result = ShowErrorMessage("请先登录!",Url.RouteUrl(MapRouteControllers.AdminLogin));
                    
                //}
                base.OnActionExecuting(filterContext);
            }
            catch (Exception ex)
            {
                filterContext.Result = ShowErrorMessage(ex.Message, Url.RouteUrl(MapRouteControllers.AdminLogin));
            }
        }

        /// <summary>
        /// 显示错误页
        /// </summary>
        /// <param name="Message"></param>
        /// <returns></returns>
        public override ActionResult ShowErrorMessage(string Message)
        {
            return ShowErrorMessage(Message, string.Empty);
        }

        /// <summary>
        /// 显示错误也并跳转
        /// </summary>
        /// <param name="Message"></param>
        /// <param name="Url"></param>
        /// <returns></returns>
        public ActionResult ShowErrorMessage(string Message, string ReturnUrl)
        {
            return RedirectToRoute(MapRouteControllers.AdminError, new { ErrorMessage = Message,ReturnUrl = ReturnUrl });
        }

    }
}
